package com.ruoyi.web.controller.system;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.EmrInfoOdsCopy;
import com.ruoyi.system.service.IEmrInfoOdsCopyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * emr原始数据Controller
 *
 * @author XZB
 * @date 2021-11-17
 */
@RestController
@RequestMapping("/system/ods")
@Api(tags = "emr原始数据")
public class EmrInfoOdsCopyController extends BaseController {

    @Autowired
    private IEmrInfoOdsCopyService emrInfoOdsCopyService;

    /**
     * 查询emr原始数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:ods:list')")
    @GetMapping("/list")
    @ApiOperation("查询emr原始数据列表")
    public TableDataInfo list(EmrInfoOdsCopy emrInfoOdsCopy) {
        startPage();
        List<EmrInfoOdsCopy> list = emrInfoOdsCopyService.selectList(emrInfoOdsCopy);
        return getDataTable(list);
    }

    /**
     * 导出emr原始数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:ods:export')")
    @Log(title = "emr原始数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出emr原始数据列表")
    public AjaxResult export(EmrInfoOdsCopy emrInfoOdsCopy) {
        List<EmrInfoOdsCopy> list = emrInfoOdsCopyService.selectList(emrInfoOdsCopy);
        ExcelUtil<EmrInfoOdsCopy> util = new ExcelUtil<>(EmrInfoOdsCopy.class);
        return util.exportExcel(list, "emr原始数据数据");
    }

    /**
     * 获取emr原始数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:ods:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取emr原始数据详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(emrInfoOdsCopyService.selectById(id));
    }

    /**
     * 新增emr原始数据
     */
    @PreAuthorize("@ss.hasPermi('system:ods:add')")
    @Log(title = "emr原始数据", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增emr原始数据")
    public AjaxResult add(@RequestBody EmrInfoOdsCopy emrInfoOdsCopy) {
        System.out.println(emrInfoOdsCopy.toString()+"------------------------------------------");
        return toAjax(emrInfoOdsCopyService.insert(emrInfoOdsCopy));
    }

    /**
     * 修改emr原始数据
     */
    @PreAuthorize("@ss.hasPermi('system:ods:edit')")
    @Log(title = "emr原始数据", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改emr原始数据")
    public AjaxResult edit(@RequestBody EmrInfoOdsCopy emrInfoOdsCopy) {
        return toAjax(emrInfoOdsCopyService.update(emrInfoOdsCopy));
    }

    /**
     * 删除emr原始数据
     */
    @PreAuthorize("@ss.hasPermi('system:ods:remove')")
    @Log(title = "emr原始数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除emr原始数据")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(emrInfoOdsCopyService.deleteByIds(ids));
    }
}
